import java.util.Scanner;

public class demo01 {
    //卡片
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int[] arr=new int[10];
        for(int i=0;i<10;i++) {
            arr[i]=2021;
        }
        int num=1;
        int flag=1;
        while(true) {
            int tmp=num;
            while(tmp!=0) {
                int n=tmp%10;
                if(arr[n]!=0) {
                    arr[n]--;
                }else {
                    flag=0;
                    break;
                }
                tmp/=10;
            }
            if(flag==0) {
                System.out.println(num-1);
                break;
            }
            num++;
        }
    }
}
